<?php $filter = array('founder','client');

$dateid	 	= isset($date_id) ? $date_id : date('d');
$monthid 	= isset($month_id) ? $month_id : date('m');
$yearid 	= isset($year_id) ? $year_id : date('y');

$ndateid = ltrim($dateid,'0');

$monthid = ltrim($monthid,'0');

if(isset($date_id)){
				
				if($dateid < 10)
				{
					$dateID = '0'.$dateid;
				}else{
					$dateID = $dateid;
				}
			}
			else{
				
				$dateID = $dateid;
			}

/*if(isset($month_id)){*/
				
				if($monthid < 10)
				{
					$monthID = '0'.$monthid;
				}else{
					$monthID = $monthid;
				}
			/*}
			else{
				$monthID = $monthid;
			}
*/

/*ECHO $today = ltrim(date('d'),'0');
ECHO $yesterday =  ltrim((date('d')),'0');

$previous_date = ($dateid - 1);
$next_date = ($dateid + 1);*/


$previous_month 	= ($monthID - 1);
$next_month		 = ($monthID + 1);

$d = '20'.$yearid;

$num = cal_days_in_month(CAL_GREGORIAN, $monthid , $d );

?>
<div class="span11">
<ul class="pager" >
<?php if($previous_month > 0) {?>
  <li class="previous">
    <a href="<?php echo site_url('admin/expenses/worksheet/'.$yearid.'/'.$previous_month.'/'.$ndateid)?>">&larr; Previous Month</a>
  </li>
  <?php } if($next_month <= 12) {?>
  <li class="next" >
    <a class="pull-right"href="<?php echo site_url('admin/expenses/worksheet/'.$yearid.'/'.$next_month.'/'.$ndateid)?>">Next Month &rarr;</a>
  </li>
  <?php }?>
</ul>

</div>
<h3 style="padding-left:10px;color:#B35D0D;">Engineer Work Details-
<?php 
$monthName = date("F", mktime(0, 0, 0, $monthid, 10));

echo  $dateid .'  '.$monthName.' '.'20'.$yearid;?></h3>

<div class="pagination" style="font-size: 8px; padding-right:14px;">
  <ul>
    <?php 	
	for($i=1;$i<=$num;$i++) {?>    
	<li
	<?php if($dateID == $i){?>
	class="active"
	<?php }?>
	>
	<?php if($dateID == $i){?>
	<a href="#"><?php echo $i?></a>
	<?php } else {?>
	<a href="<?php echo site_url('admin/expenses/worksheet/'.$yearid.'/'.$monthid.'/'.$i)?>"><?php echo $i?></a>
	<?php }?>
	
	
	</li>
	<?php }?>
  </ul>
</div>

<!--<ul class="pager">
<?php if($previous_month > 0) {?>
  <li class="previous">
    <a href="<?php echo site_url('admin/expenses/worksheet/'.$yearid.'/'.$previous_month.'/'.$today)?>">&larr; Today</a>
  </li>
  <?php } if($next_month <= 12) {?>
  <li class="next">
    <a href="<?php echo site_url('admin/expenses/worksheet/'.$yearid.'/'.$next_month.'/'.$yesterday)?>">Yesterday &rarr;</a>
  </li>
  <?php }?>
</ul>-->
<div class="row-fluid">
<div class="span12 pad_all">
<div id="date_wise">
<table class="table table-bordered table-striped table-condensed">	
	<tr>
		<th style="color:#771843">Name</th>
		<th style="color:#771843">Receipt No.</th>
		<th style="color:#771843"> Assigned For</th>
		<th style="color:#771843"> Status</th>
		<th style="color:#771843"> Expenses </th>

	</tr>
	<?php foreach($users as $user):
	/*if((!$this->ion_auth->is_admin($user->id)) AND $this->ion_auth->is_active($user->id) AND  !$this->ion_auth->is_client($user->id)){*/	
	?>
	<tr>
		<td ><b style="color:#009BD4; text-align="center">
		<?php echo $user->username;?> </b>
		
		</td>
		<td>
		<?php   foreach ($this->expenses_model->get_case_date($user->id,$date) as $case){?>
		
		<p style="color:#076D3D;"align="center"><?php echo $case->case_no;?> </p><br>
		<?php } ?>
		<?php   foreach ($this->expenses_model->get_nonwarranty_case_date($user->id,$date) as $non_case){?>
		
		<p style="color:#076D3D;"align="center"><?php echo $non_case->case_no;?> </p><br>
		<?php } ?>
		</td>
		<td>
		<?php   foreach ($this->expenses_model->get_case_date($user->id,$date) as $case){?>
		
		<p style="color:#076D3D;"align="center"><?php if( $case->stat <= 3) { echo "Diagnosis"; } else { echo  "Repair" ;}?> </p><br>
		<?php } ?>
		<?php   foreach ($this->expenses_model->get_nonwarranty_case_date($user->id,$date) as $non_case){?>
		
		<p style="color:#076D3D;"align="center"><?php if($non_case->non_stat<=3) {echo "Diagnosis"; } else { echo "Repair"; }?> </p><br>
		<?php } ?>
		</td>
		<td>
		<?php   foreach ($this->expenses_model->get_case_date($user->id,$date) as $case){?>
		
		<p style="color:#076D3D;"align="center"><?php echo $case->warranty_status;?> </p><br>
		<?php } ?>
		<?php   foreach ($this->expenses_model->get_nonwarranty_case_date($user->id,$date) as $non_case){?>
		
		<p style="color:#076D3D;"align="center"><?php echo $non_case->non_status;?> </p><br>
		<?php } ?>
		</td>
		<td>
			<?php   foreach ($this->expenses_model->get_case_date($user->id,$date) as $case){?>
		<?php $data=$this->expenses_model->get_expense_detail($case->id)->row();?>
		<p style="color:#076D3D;"align="center"><?php if(!empty($data)){ echo $data->total;} else { echo ""; } ?>
		<?php } ?>
        <?php   foreach ($this->expenses_model->get_nonwarranty_case_date($user->id,$date) as $non_case){?>
		<?php $data1=$this->expenses_model->get_expense_detail_nonwarranty($non_case->id)->row();?>
		<p style="color:#076D3D;"align="center"><?php if(!empty($data1)){ echo $data1->total;} else { echo ""; } ?> </p><br>
		<?php } ?>
		</td>	
		
	</tr>
	<?php  endforeach ;?>
</table>
</div>
</div>
<!--<div class="span1">
	<header>Links</header>
	
</div>
